
#region license
/// Copyright (c) 2007 Rodrigo B. de Oliveira, Jb Evain and the
/// individuals listed on the ChangeLog entries.
/// 
/// Permission is hereby granted, free of charge, to any person obtaining
/// a copy of this software and associated documentation files (the
/// "Software"), to deal in the Software without restriction, including
/// without limitation the rights to use, copy, modify, merge, publish,
/// distribute, sublicense, and/or sell copies of the Software, and to
/// permit persons to whom the Software is furnished to do so, subject to
/// the following conditions:
/// 
/// The above copyright notice and this permission notice shall be
/// included in all copies or substantial portions of the Software.
/// 
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
/// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
/// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
/// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
/// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
/// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
/// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endregion
//
// DO NOT EDIT THIS FILE!
//
// This file was generated automatically by astgen.boo.
//

namespace Milo.Ast
{	
	using System.Collections;
	using System.Runtime.Serialization;
	
	[System.Serializable]
	public partial class TryStatement : Statement
	{
		protected Block _protectedBlock;

		protected ExceptionHandlerCollection _exceptionHandlers;

		protected Block _ensureBlock;

	
		new public TryStatement CloneNode()
		{
			return Clone() as TryStatement;
		}
		override public NodeType NodeType
		{
			get
			{
				return NodeType.TryStatement;
			}
		}
		
		override public void Accept(IAstVisitor visitor)
		{
			visitor.OnTryStatement(this);
		}
		override public bool Matches(Node node)
		{	
			TryStatement other = node as TryStatement;
			if (null == other) return false;
			if (!Node.Matches(_modifier, other._modifier)) return NoMatch("TryStatement._modifier");
			if (!Node.Matches(_protectedBlock, other._protectedBlock)) return NoMatch("TryStatement._protectedBlock");
			if (!Node.AllMatch(_exceptionHandlers, other._exceptionHandlers)) return NoMatch("TryStatement._exceptionHandlers");
			if (!Node.Matches(_ensureBlock, other._ensureBlock)) return NoMatch("TryStatement._ensureBlock");
			return true;
		}
	
		override public bool Replace(Node existing, Node newNode)
		{
			if (base.Replace(existing, newNode))
			{
				return true;
			}
			if (_modifier == existing)
			{
				this.Modifier = (StatementModifier)newNode;
				return true;
			}
			if (_protectedBlock == existing)
			{
				this.ProtectedBlock = (Block)newNode;
				return true;
			}
			if (_exceptionHandlers != null)
			{
				ExceptionHandler item = existing as ExceptionHandler;
				if (null != item)
				{
					ExceptionHandler newItem = (ExceptionHandler)newNode;
					if (_exceptionHandlers.Replace(item, newItem))
					{
						return true;
					}
				}
			}
			if (_ensureBlock == existing)
			{
				this.EnsureBlock = (Block)newNode;
				return true;
			}
			return false;
		}
		
		override public object Clone()
		{
			TryStatement clone = (TryStatement)FormatterServices.GetUninitializedObject(typeof(TryStatement));
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
		
			if (null != _modifier)
			{
				clone._modifier = _modifier.Clone() as StatementModifier;
				clone._modifier.InitializeParent(clone);
			}
			if (null != _protectedBlock)
			{
				clone._protectedBlock = _protectedBlock.Clone() as Block;
				clone._protectedBlock.InitializeParent(clone);
			}
			if (null != _exceptionHandlers)
			{
				clone._exceptionHandlers = _exceptionHandlers.Clone() as ExceptionHandlerCollection;
				clone._exceptionHandlers.InitializeParent(clone);
			}
			if (null != _ensureBlock)
			{
				clone._ensureBlock = _ensureBlock.Clone() as Block;
				clone._ensureBlock.InitializeParent(clone);
			}
			return clone;
		}
	

		[System.Xml.Serialization.XmlElement]
		public Block ProtectedBlock
		{
			get
			{
			if (_protectedBlock == null)
			{
				_protectedBlock = new Block();
				_protectedBlock.InitializeParent(this);
			}

				return _protectedBlock;
			}

			set
			{
				if (_protectedBlock != value)
				{
					_protectedBlock = value;
					if (null != _protectedBlock)
					{
						_protectedBlock.InitializeParent(this);
					}
				}
			}

		}
		

		[System.Xml.Serialization.XmlElement]
		public ExceptionHandlerCollection ExceptionHandlers
		{
			get
			{

			if (_exceptionHandlers == null) _exceptionHandlers = new ExceptionHandlerCollection(this);

				return _exceptionHandlers;
			}

			set
			{
				if (_exceptionHandlers != value)
				{
					_exceptionHandlers = value;
					if (null != _exceptionHandlers)
					{
						_exceptionHandlers.InitializeParent(this);
					}
				}
			}

		}
		

		[System.Xml.Serialization.XmlElement]
		public Block EnsureBlock
		{
			get
			{

				return _ensureBlock;
			}

			set
			{
				if (_ensureBlock != value)
				{
					_ensureBlock = value;
					if (null != _ensureBlock)
					{
						_ensureBlock.InitializeParent(this);
					}
				}
			}

		}
		

	}
}

